<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>
<style type="text/css">
<!--
#namediv {
	position:absolute;
	width:208px;
	height:22px;
	z-index:1;
	left: 234px;
	top: 12px;
	background-color: #99FF66;
}
#passdiv {
	position:absolute;
	width:200px;
	height:23px;
	z-index:2;
	left: 234px;
	top: 38px;
	background-color: #99FF99;
}
-->
</style>
<script type="text/javascript" src="script/jquery.min.js"></script>
<script type="text/javascript">
	$(document).ready(function(){
		$("#btnconfirm").click( function(){
			 $.ajax({    	type: "post",
				 			url: "NewFile.jsp?id=tom",  
				 			datatype: "json",    
				 			contentType: "application/json",    
				 			data:"{}",    
				 			success: function(result){ 
				 				alert(result);
				 				$("#passdiv").html(result);
				 				}   
				 			});
			});

							$("#btn").click( function(){
								var name = $("#uname").val();
								var pass = $("#upassword").val();
								if (pass.trim().length < 1) {
									$("#passdiv").html("密码不能为空 ").css({
										visibility : "visible"
									});
								}else {
									var part={
											username : name ,
											password : pass
											};
									$.post("TestAjax", part, function(data, status){
										alert(data);
										if ("wohao"== data) {
											$("#passdiv").html("密码正确 ").css({
												visibility : "visible"
											});
										} else {
											$("#passdiv").html("aaaa").css({
												visibility : "visible"
											});
											//location.href="mainweb.html";
										} 
											
									});
									
								}	 //end else
											 
											 
							})
							$("#passdiv").ajaxError(function(){
							    alert("发生错误！");
							  });
							
					});
	
</script>

</head>
<body>
	<form action="" method="get">
		NAME:<input name="uname" id="uname" type="text" /><br/>
		<div id="namediv"></div>
		PASS:<input name="upassword" id="upassword" type="text" /><br/>
		<div id="passdiv"></div>
		<input name="submit" id="btn"  type="button" value="confirm" />
		<input name="res" id="btnconfirm"   type="button" value="ok" />
</form>
</body>
</html>